package com.shuang.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shuang.pojo.ExtendDbGoodsProperty;
import com.shuang.service.DbGoodsPropertyService;

@Controller
@RequestMapping("/property")
public class DbGoodsPropertyHanlder {

	@Resource(name="dbGoodsPropertyService")
	private DbGoodsPropertyService  dbGoodsPropertyService;
	
	@RequestMapping("/findPropertyById/{cId}")
	@ResponseBody
	public List<ExtendDbGoodsProperty> findPropertyById(@PathVariable Long cId){
		return dbGoodsPropertyService.findPropertyById(cId);
		
	}
	
	@RequestMapping("/savePropertyParam/{cId}")
	@ResponseBody
	public Map<String,Object> savePropertyParam(@PathVariable Long cId,String paramData){
		if(cId==null||paramData==null||paramData==""){
			Map<String, Object> map=new HashMap<String, Object>();
			map.put("status", 403);
			return map;
		}
		return dbGoodsPropertyService.savePropertyParam(cId,paramData);
	}
	
	
	
	@RequestMapping("/updatePropertyParam/{gpId}")
	@ResponseBody
	public Map<String,Object> updatePropertyParam(@PathVariable Long gpId,String paramData) throws Exception{
		if(gpId==null||paramData==null||paramData==""){
			Map<String, Object> map=new HashMap<String, Object>();
			map.put("status", 403);
			return map;
		}
		return dbGoodsPropertyService.updatePropertyParam(gpId,paramData);
	}
	
	
	@RequestMapping("/selectPropertyInfoByCid/{cId}")
	@ResponseBody
	public Map<String,Object> selectPropertyInfoByCid(@PathVariable Long cId){
		if(cId==null){
			Map<String, Object> map=new HashMap<String, Object>();
			map.put("status", 403);
			return map;
		}
		return dbGoodsPropertyService.selectPropertyInfoByCid(cId);
	}
}
